package com.jt.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.pojo.Item;
import com.jt.pojo.ItemDesc;
import com.jt.service.DubboItemService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ItemController{
    @Reference(check = false)
    private DubboItemService dubboItemService;

    @RequestMapping("/items/{itemId}")
    public String findItemById(@PathVariable Long itemId, Model model){
        //远程访问获取商品信息
        Item item = dubboItemService.findItemById(itemId);
        //远程访问获取商品详细信息
        ItemDesc itemDesc = dubboItemService.findItemDescById(itemId);
        //3.将数据传到页面中
        model.addAttribute("item",item);
        model.addAttribute("itemDesc",itemDesc);
        return "item";
    }

}
